import { _decorator } from 'cc'
import { State } from '../base/State'
import { StateMachine } from './StateMachine'

/** 子状态机基类 */
export abstract class SubStateMachine {
  // 当前状态
  private _currentState: State = null
  public get currentState(): State {
    return this._currentState
  }
  public set currentState(value: State) {
    this._currentState = value
    this.currentState.run() // 播放动画
  }
  // 存储状态机集合
  stateMachines: Map<string, State> = new Map()

  constructor(public fsm: StateMachine) {}

  /** 运行状态机 切换当前状态 */
  abstract run()
}
